package chelydra.sharelydra.server.web.service;

import chelydra.sharelydra.server.ejb.SLSUser;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import chelydra.sharelydra.server.web.SLSServlet;

/**
 *
 * @author scallion
 */
public class SLSProposeServlet extends SLSServlet {

	public SLSProposeServlet() {
		this.action_name = "propose";
	}

	@Override
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {

		this.initManager(request);
		SLSUser user = this.initAttributes(request,response);

		if (user != null){
			if (request.getParameter("proposed")!=null) {
				this.manager.sendFriendshipProposal(user, this.manager.retrieveUserWithLogin(request.getParameter("proposed")));
			} else {
				this.rd = this.rd = request.getRequestDispatcher("/WEB-INF/jsp/fail.jsp");
			}
		}

		this.rd.forward(request, response);
	}
}


